home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Applications / Assorted Programs / PCB Cad / PCBROUTE.C < prev    next >
C/C++ Source or Header  |  1990-10-10  |  4KB  |  109 lines

  1. /*
  2. ** printed circuit board autorouter, Copyright (C) Randy Nevin 1989.
  3. **
  4. ** you may give this software to anyone, make as many copies as you like, and
  5. ** post it on public computer bulletin boards and file servers. you may not
  6. ** sell it or charge any fee for distribution (except for media and postage),
  7. ** remove this comment or the copyright notice from the code, or claim that
  8. ** you wrote this code or anything derived from it. you may modify the code as
  9. ** much as you want (please document clearly with comments, and maintain the
  10. ** coding style), but programs which are derived from this one are subject to
  11. ** the conditions stated here. i am providing this code so that people can
  12. ** learn from it, so if you distribute it, please include source code, not
  13. ** just executables. contact me to report bugs or suggest enhancements; i do
  14. ** not guarantee support, but i will make an effort in good faith to help you,
  15. ** and i want to act as a central clearing house for future versions. you
  16. ** should contact me before undertaking a significant development effort, to
  17. ** avoid reinventing the wheel. if you come up with an enhancement you
  18. ** consider particularly useful, i would appreciate being informed so that it
  19. ** can be incorporated in future versions. my address is: Randy Nevin,
  20. ** 1731 211th PL NE, Redmond, WA 98053. this code is available directly from
  21. ** the author; just send a floppy and a self-addressed floppy mailer with
  22. ** sufficient postage.
  23. **
  24. ** HISTORY
  25. ** (name        date        description)
  26. ** ----------------------------------------------------
  27. ** randy nevin        2/1/89        initial version
  28. ** randy nevin        2/4/89        made retrace table driven, instead of
  29. **                    doubly-nested switch statements.
  30. ** randy nevin        2/4/89        changed dir from int to char (cut
  31. **                    storage for it in half).
  32. ** randy nevin        2/8/89        changed SetQueue and ReSetQueue to
  33. **                    give priority to goal nodes.
  34. ** randy nevin        2/11/89        don't output incremental search
  35. **                    results if stdout is redirected.
  36. ** randy nevin        2/11/89        released version 1.00
  37. */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. /*#include <io.h>*/
  42. #include <time.h>
  43. #include <string.h>
  44. #include "cell.h"
  45.  
  46. #ifdef THINK_C
  47. #include <console.h>
  48. #endif
  49.  
  50. /*
  51. ** if you run out of memory while routing large boards, there are two things
  52. ** you can do: (1) go into your config.sys file and disable everything you
  53. ** don't need. getting rid of things like ansi.sys, ramdisks, disk caches, and
  54. ** other terminate and stay resident (tsr) programs can free a lot of memory.
  55. ** (2) link the router, inspect the .map file, relink with the /CPARMAXALLOC:n
  56. ** switch, where n is calculated to allow for a near heap of about 5k. read
  57. ** the linker documentation before you do this. for me, the route.map file
  58. ** says the program needs 81EFh bytes. to this i add 1400h (5k) for a near
  59. ** heap to get 95EFh bytes or 95Fh paragraphs, which is 2399 decimal.
  60. */
  61.  
  62. int justboard = 0; /* need all data structures, not just the board */
  63.  
  64. extern void Initialize( FILE * );
  65. extern void Solve( void );
  66. extern void Report( FILE * );
  67.  
  68. void main( int, char *[] );
  69.  
  70. void main ( argc, argv ) /* input board, route traces, output routed board */
  71.     int argc;
  72.     char *argv[];
  73.     {
  74.     char *self, *p;
  75.     FILE *fin, *fout;
  76.     long start, stop;
  77.     
  78. #ifdef THINK_C
  79.     argc = ccommand (&argv);        /* simulate command-line arguments */
  80. #endif
  81.  
  82.  
  83.     printf( "Copyright (C) Randy Nevin, 1989. Version 1.00\n" );
  84.     printf( "See source code for rights granted.\n\n" );
  85.     start = time( NULL );
  86.     self = argv[0];
  87.     /* get rid of initial part of path */
  88.     if ((p = strrchr( self, '\\' )) || (p = strrchr( self, ':' )))
  89.         self = ++p;
  90.     if (argc != 3) { /* need infile and outfile */
  91.         printf( "usage: %s infile outfile\n", self );
  92.         exit( -1 );
  93.         }
  94.     if (!(fin = fopen( argv[1], "r" ))) {
  95.         printf( "can't open %s\n", argv[1] );
  96.         exit( -1 );
  97.         }
  98.     if (!(fout = fopen( argv[2], "wb" ))) {
  99.         printf( "can't open %s\n", argv[2] );
  100.         exit( -1 );
  101.         }
  102.     Initialize( fin );
  103.     Solve();
  104.     Report( fout );
  105.     stop = time( NULL ) - start;
  106.     printf( "time = %ld second%s\n", stop, (stop == 1) ? "" : "s" );
  107.     exit( 0 );
  108.     }
  109.